<?php
if(isset($_POST['loginoke'])) {
	$u = $_POST['usernamelg'];
	$p = $_POST['passwordlg'];
	if (get_magic_quotes_gpc()==false) {
           $u = mysql_real_escape_string($u); 
		   $p = mysql_real_escape_string($p);
    }
	$pm = md5($p);
	
	include "cnn.php";
	$sql = "SELECT * FROM lib_user WHERE use_username ='".$u."' AND use_password ='".$pm."'";
	$query = mysql_query($sql) or die("loi truy van: ".mysql_error());
	$rown = mysql_num_rows($query);
	//$rw = mysql_fetch_array($query);
	
	if($rown != 1) {
		
		
	header("location:home.php");
		
		
	}
	else {
		
		if($_POST['remember'] = 'on') {
			      setcookie("loginck",$_POST['usernamelg'],time()+3600);
		   
		             	
					 
					   header("location:home.php");
			          
		       }
	           else {
			          
					  
		                header("location:home.php");
		       }
		
	}
	
}
else {
	
$gd=<<<GDLG
<a href="#login-box" class="login-window"><img src="img/login.png"></a> 

<div id="login-box" class="login-popup">
        <a href="#" class="close"><img src="img/close.png" class="btn_close" title="Close Window" alt="Close" /></a>
          <form method="post" class="signin" action="" id="login_form">
                <fieldset class="textbox">
                  
                <label class="username">
                <span>Username</span>
                <input id="usernamelg" name="usernamelg" value="" type="text" class="required">
                </label>
                <label class="password">
                <span>Password</span>
                <input id="passwordlg" name="passwordlg" value="" type="password"  class="required">
                </label>
                <input class="subm" type="submit" value="Sign in" name="loginoke">
                <span>Remember login?  <input type="checkbox" name="remember"></span>       
                </fieldset>
          </form>
</div>  
GDLG;
echo $gd;
}

?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
<link rel="stylesheet" type="text/css" href="style/stylelogin.css">
<!--script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script-->
<script type="text/javascript" src="js/jquery-1.6.4.js"></script>
<script type="text/javascript" src="js/loginjs.js"></script> 
<script type="text/javascript" src="js/jquery-validation-1.9.0/jquery.validate.min.js"></script> 
<script type="text/javascript" src="js/validate.js"> </script>
</head>
<body>
</body> 
</html>